<template>
  <c-form-dialog
    :visible.sync="innerVisible"
    :form-items="formItems"
    :form-data="formData"
    :table-name="tableName"
    :table-id="tableId"
    @close="beforeClose"
    @dismiss="beforeClose"
    @success="handleSuccess"
  ></c-form-dialog>
</template>

<script>
import { enumRiskMethod } from '@/credit/plugins/enum'

export default {
  components: {},
  props: {
    visible: Boolean,
    tableId: String,
    goodsId: String,
    formData: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {
      tableName: 'industrial_package_risk',
      formItems: [
        {
          tag: 'c-select',
          itemAttrs: {
            label: '风控措施',
            rules: [{ required: true, message: '请选择风控措施', trigger: 'blur' }],
          },
          attrs: {
            key: 'risk_name',
            value: '',
            class: 'form-control-ml',
            placeholder: '请选择风控措施',
            options: enumRiskMethod,
          },
        },
        {
          tag: 'input',
          itemAttrs: {
            label: '措施方案',
            rules: [{ required: true, message: '请输入措施方案', trigger: 'blur' }],
          },
          attrs: { key: 'risk_des', value: '', placeholder: '请输入措施方案' },
        },
        {
          tag: 'input',
          itemAttrs: {
            label: '监控指标',
            rules: [{ required: true, message: '请输入监控指标', trigger: 'blur' }],
          },
          attrs: { key: 'monitor_des', value: '', placeholder: '请输入监控指标' },
        },
        {
          tag: 'input',
          itemAttrs: { label: 'industrial_package_id' },
          attrs: { key: 'industrial_package_id', value: '' },
          ifShow: false,
          getValue: () => this.goodsId,
        },
      ],
      innerVisible: false,
    }
  },
  computed: {},
  watch: {
    visible(val) {
      this.innerVisible = val
    },
  },
  created() {},
  mounted() {},
  methods: {
    handleSuccess(res) {
      this.$emit('update:visible', false)
      this.$emit('success', res)
    },
    beforeClose() {
      this.$emit('update:visible', false)
    },
  },
}
</script>

<style lang="scss" scoped></style>
